import Vue from "vue"
import VueRouter from "vue-router"
import MyMain from '@/views/pages/Main'
import MyUser from '@/views/pages/User'
import MyHome from '@/views/pages/Home'

//引入组件,这里you
// import {MainCms} from "../views/MainCms.vue"
// 要告诉 vue 使用 vueRouter
Vue.use(VueRouter)

const routes = [{

    path: '/',
    component: MyMain,
    children: [
        {
            path: '/home',
            name: 'home',
            component: MyHome
        },
        {
            path: '/user',
            name: 'user',
            component: MyUser
        },
        {
            path: '/mall',
            name: 'mall',
            component: () => import('@/views/pages/Mall/index.vue')
        },
        {
            path: '/page1',
            name: 'page1',
            component: () => import('@/views/pages/Others/pageOne.vue')
        },
        {
            path: '/page2',
            name: 'page2',
            component: () => import('@/views/pages/Others/pageTwo.vue')
        },
    ]
},
{
    path: "/login",
    name: "login",
    component: () => import("@/views/backend/login/indexLogin.vue")
},
{
    path: "/register",
    name: "register",
    component: () => import("@/views/backend/register/indexRegister.vue")
},
{
    path: "/articleEdit",
    name: "articleEdit",
    component: () => import("@/views/backend/articleEdit/articleEdit.vue")

}
]
//创建router
const router = new VueRouter({
    mode: "history",
    routes
})

//解决点击重复路由报错信息
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => err)
}

export default router